#version 450 core
in vec3 vertex_normal;
in vec2 vertex_tex_coord;
in vec3 vertex_position;
in vec3 vertex_color;
out vec4 fragment_color;

layout (location = 4) uniform vec3 light_color;
layout (location = 5) uniform vec3 light_position;
layout (location = 6) uniform vec3 ambient_color;
layout (location = 7) uniform vec3 viewer_position; 
layout (location = 8) uniform float Ka;
layout (location = 9) uniform float Kd;
layout (location = 10) uniform float Ks;
layout (location = 11) uniform float shininess;

void main()
{
    vec3 ambient = Ka * ambient_color;

    vec3 N = normalize(vertex_normal);
    vec3 L = normalize(light_position - vertex_position);
    vec3 diffuse = Kd * max(dot(N, L), 0.0) * light_color;

    vec3 V = normalize(viewer_position - vertex_position);
    vec3 R = reflect(-L, N);  
    vec3 specular = Ks * pow(max(dot(R, V), 0.0), shininess) * light_color;  

    fragment_color = vec4((ambient + diffuse + specular) * vertex_color, 1.0);
}



